home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Network Support Library
/
RoseWare - Network Support Library.iso
/
apidev
/
mhs_c.arc
/
INPOST.ARC
/
INPOST.C
< prev
next >
Wrap
C/C++ Source or Header
|
1988-06-27
|
5KB
|
251 lines
/* (C) Copyright 1987,1988 - TaxWare/Neil W. Taylor */
#include "cctypes.h"
#define WORKSPACE 2000
/* ****************** GLOBAL VARIABLES ****************** */
int Dbug = 0;
int comType = 0;
int answer = 0;
int NotMergeFileNamePtr = -1;
int ErrorsInThisFile = 0;
int WarningsInThisFile = 0;
int warningFound;
int InFile;
int OutFile;
FILE *CCHandle;
char InFileName[256];
char OutFileName[256];
char workArea[64]; /* argv[6] */
char messageBuffer[8192];
MCB MCBStruct;
int lineNumber = 0, lNumber = 0;
char Out[WORKSPACE];
char originatingHost[37];
long fileSize = 0;
char InExtension[] = ".EXP";
char OutExtension[] = ".MCB";
char *CommandTypes[] = {
"",
"Message:",
"Contents:",
"From:",
"Forward",
"Date:",
"To:",
"cc:",
"Subject:",
"Text ",
"Graphic",
"File",
0
};
char *ErrorTypes[] = {
"Unknown Error",
"Syntax",
"Cannot Open File",
"Cannot Create Output",
};
struct {
char name[40];
char loc[10];
char addr[80];
char comment[80];
} CCRec;
void UpperCase();
int Parse();
extern int OpenInputFile();
extern int OpenOutputFile();
int GetCommandType();
int GetParameter();
int SetUpOutFile();
void FinishUpOutFile();
void Error();
void Warning();
int MergeIt();
void InitMCB();
void WriteLine();
void main(argc, argv)
int argc;
char *argv[];
{
int exitCode = ERROR_ENCOUNTERED, ccode, i;
char commandLine[256], command[80], *p;
system("CLS");
for ( i = 1; i < 6; i++ )
WriteLine("\0");
WriteLine(" cc:Mail / MHS Gateway\0");
WriteLine("\0");
WriteLine(" Converting message(s) to MHS format...\0");
WriteLine("\0");
if (argc != 7 ) goto Out;
sprintf(commandLine, "Z:MAP P:=%s > NUL:", argv[4]);
system(commandLine);
strcpy(workArea, "P:");
sprintf(commandLine, "Z:EXPORT %s %s %s @%s directory > NUL:",argv[1],
argv[3], workArea, workArea);
system(commandLine);
CCHandle = fopen("P:CCMDIR.EXP", "r");
if ( CCHandle == NULL )
goto Out;
ExportNext:
p = fgets(CCRec.name,
sizeof(CCRec.name),
CCHandle);
if ( p == NULL ) goto Out;
p = fgets(CCRec.loc, sizeof(CCRec.loc), CCHandle);
p = fgets(CCRec.addr, sizeof(CCRec.addr), CCHandle);
p = fgets(CCRec.comment, sizeof(CCRec.comment), CCHandle);
if ( CCRec.loc[6] != 'P' ) goto ExportNext;
UpperCase(&CCRec.addr[6]);
if ( CCRec.addr[6] == 'M' && CCRec.addr[7] == 'H' && CCRec.addr[8] == 'S' )
goto DoIt;
else
goto ExportNext;
DoIt:
CCRec.name[strlen(CCRec.name)-1] = '\0';
sprintf(commandLine, "Z:\EXPORT %s %s %s @%s >NUL:",&CCRec.name[6],
argv[3], workArea, workArea);
system(commandLine);
sprintf(InFileName, "%sCCMAIL.EXP", workArea);
/* convert filename to upper case */
UpperCase(InFileName);
/* Convert CC to MCB */
ccode = OpenInputFile();
if ( ccode == -1 ) {
/* Error(CANNOT_OPEN_FILE); */
unlink("P:CCMAIL.EXP");
goto ExportNext;
}
strcpy(originatingHost, argv[2]);
InitMCB();
/* PARSE the temporary file CCMAIL.EXP created by the EXPORT utility */
ccode = Parse();
if ( ccode ) /* CANNOT_CREATE_OUTPUT or FATAL_ERROR_ENCOUNTERED */
goto CloseInput;
if ( ccode == NO_ERROR ) {
close(InFile);
WriteMCBFile();
/* STUB take out the -V later */
sprintf(commandLine, "Z:\SEAL -F%sCCMAIL.MCB -V >NUL:", workArea);
system(commandLine);
/* now delete the CCMAIL.* files in the workarea */
unlink("P:CCMAIL.ANS");
close(InFile);
unlink("P:CCMAIL.EXP");
goto ExportNext;
}
CloseInput:
close(InFile);
goto ExportNext;
Out:
exitCode = NO_ERROR; /* ?? */
fclose(CCHandle);
unlink("P:CCMDIR.EXP");
system("CLS");
exit(exitCode);
}
void EOL(string)
char *string;
{
/* string[0] = '\15';
string[1] = '\12';
string[2] = '\0'; */
/* strcpy(string, "\15\12"); */
string[0] = '\0';
}
void InitMCB()
{
/* 1 */
strcpy(MCBStruct.MHSVersion, "MHS-1");
/* 2 */
MCBStruct.headerLines = 18;
/* 3 */
MCBStruct.MCBType = 0; /* message MCB */
/* 4 */
EOL(MCBStruct.deliveryOptions);
/* 5 */
/* EOL(MCBStruct.originatingApplicationName); */
strcpy(MCBStruct.originatingApplicationName, "EMAIL");
/* 6 */
EOL(MCBStruct.originatingUsername);
/* 7 */
/* EOL(MCBStruct.originatingHost); */
strcpy(MCBStruct.originatingHost, originatingHost);
/* 8 */
EOL(MCBStruct.destinationUsername);
/* 9 */
EOL(MCBStruct.destinationHost);
/* 10 */
EOL(MCBStruct.messageSubject);
/* 11 */
EOL(MCBStruct.attachmentFilename);
/* 12 */
EOL(MCBStruct.sealedMessageID);
/* 13 */
EOL(MCBStruct.referencedMessageID);
/* 14 */
EOL(MCBStruct.dateSealed);
/* 15 */
EOL(MCBStruct.dateUnsealed);
/* 16 */
MCBStruct.contentTypeOfAttachmentFile = 0; /* no file */
/* 17 */
MCBStruct.statusReport = 0;
/* 18 */
EOL(MCBStruct.blankLine);
messageBuffer[0] = '\0';
}
void WriteLine(string)
char *string;
{
/* char line[80], temp[79];
strncpy(temp, " ",
76-strlen(string));
sprintf(line, "│%s%s\n", string, temp);
printf(line); */
printf("%s\n",string);
}